package cn.boysoft.module.security.model.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

import cn.boysoft.core.annotation.JEEEntityDeclare;
import cn.boysoft.core.model.entity.BaseEntity;

@Table(name="jee_resource")
@Entity
@JEEEntityDeclare(name="资源信息")
public class ResourceEntity extends BaseEntity{
	@Column(length = 36)
	private String code;
	@Column(length = 36)
	private String name;
	@Column(length = 255)
	private String remark;
	@Enumerated(EnumType.ORDINAL)
	private ResourceTypeEnum resourceType;
	@Type(type="yes_no")
	private Boolean enabled = true;
	@Column(name="sortNo")
	private Integer sortNo = 0;
	@Column(name="viewName",length=150)
	private String viewName;
	
	@JoinColumn(name = "parentId")
	@ManyToOne
	private ResourceEntity parent;
	
	@OneToMany(mappedBy="parent", cascade={CascadeType.REMOVE} ,targetEntity=ResourceEntity.class)
	private Set<ResourceEntity> children = new HashSet<ResourceEntity>();
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public ResourceTypeEnum getResourceType() {
		return resourceType;
	}
	public void setResourceType(ResourceTypeEnum resourceType) {
		this.resourceType = resourceType;
	}
	public ResourceEntity getParent() {
		return parent;
	}
	public void setParent(ResourceEntity parent) {
		this.parent = parent;
	}
	public Boolean getEnabled() {
		return enabled;
	}
	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}
	public Integer getSortNo() {
		return sortNo;
	}
	public void setSortNo(Integer sortNo) {
		this.sortNo = sortNo;
	}
	public Set<ResourceEntity> getChildren() {
		return children;
	}
	public void setChildren(Set<ResourceEntity> children) {
		this.children = children;
	}
	public String getViewName() {
		return viewName;
	}
	public void setViewName(String viewName) {
		this.viewName = viewName;
	}
	
}
